package edu.isquen.core.datasource.action;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import edu.isquen.core.base.model.ValueObject;
import edu.isquen.core.datasource.model.DataSource;
import edu.isquen.core.datasource.service.DataSourceService;
import edu.isquen.util.factory.ServiceFactory;

public class DataSourceHelper {
	
	public Map<String, String> getDataSourceList(){
		Map<String, String> map=new HashMap<String, String>();
		map.put("", "——选择数据源——");
		try {
			DataSourceService dtProcess = (DataSourceService) ServiceFactory.createProcess(DataSourceService.class);
			Collection<ValueObject> dtlist=dtProcess.doQuery().datas;
			for(Iterator<ValueObject> iter=dtlist.iterator();iter.hasNext();){
				DataSource dt=(DataSource) iter.next();
				if(dt!=null){
					map.put(dt.getId(), dt.getName());
				}
			}
		} catch (Exception e) {
			return map;
		}
		return map;
	}
}
